Release 10.1A: OpenEdge Development:
ProDataSets
ProDataSet buffer FIND-FAILED event
A similar condition to the
OFF-ENDevent that happens when you go past the end of a set of rows is when aFINDon a table fails. There is aFIND-FAILEDevent for a ProDataSet temp-table buffer, which is triggered when any attempt is made to find a row that is not in the table. This can be the result of aFINDstatement, aFINDmethod on a buffer (FIND-FIRSTandFIND-UNIQUE), or an action that implicitly finds a row in a ProDataSet temp-table. For example:
If an application procedure is looking for a row that may have been cached already in a ProDataSet, and it is not there, this event gives the procedure the opportunity to suspend the
FINDin order retrieve the row in question, and to do anything else that might be appropriate. So the event procedure could retrieve just the row for which theFINDfailed, and add it to the local cache, or it could retrieve a set of related rows, or anything else. The event handler has to be able to determine from the context of the ProDataSet, which as always is passed into it as anINPUTparameter, what the missing data is. For example, if the current row in thettOrdertable as passed in does not yet have itsOrderLines, then the code can make a call back to the server to returnOrderLinesof the currentOrderand append them to the ProDataSet. However, the event handler does not have direct access to the where-clause used on theFINDthat failed.As with the
OFF-ENDevent, it is completely transparent to the 4GL code that causes the initial failure that theFINDever failed in the first place. If the event handler is able to add the needed row to the temp-table andRETURN NO-APPLY, the original statement simply succeeds as if the row had always been there.As with the
OFF-ENDevent, this event is supported only forFINDson ProDataSet temp-table buffers, not other buffers.
FIND-FAILEDcan be triggered by the staticFINDandFIND FIRSTstatements and the dynamic method equivalentsFIND-UNIQUEandFIND-FIRST.FIND-FAILEDdoes not occur for anyFINDNEXTorLASTstatement or their equivalentGETmethods for queries, or for theCAN-FINDfunction. By contrast,FIND NEXTandFIND LASTconditions that don’t yield a row of data are handled by the queryOFF-ENDevent.If a unique find (that is, an unqualified
FINDstatement or aFIND-UNIQUEmethod) fails due to ambiguity, the event does not fire, since the problem in that case is not that the row does not exist, but that there are too many matches.It is important that the event handler itself not do any
FINDson the same buffer that the event is defined on. Attempting to do this will cause an error.The "Setting up an event handler for the FIND-FAILED buffer event" section illustrates how to use the
FIND-FAILEDevent to fill inItemrows in the client-side user interface as they are explicitly referenced for the first time by anOrderLinethat uses thatItem.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |